'''工具类文件'''
import config
import json


def parse_login_data():
    '''
    解析登录数据json
    :return: 列表数据
    '''
    login_data_path = config.PROJECT_PATH + '/data/login_data.json'
    with open(login_data_path, encoding='utf-8') as file:
        data_list = json.load(file)
        temp_list = []
        for data_dic in data_list:
            login_data = data_dic['login_data']
            success = data_dic['success']
            code = data_dic['code']
            message = data_dic['message']
            temp_list.append((login_data, success, code, message))
    return temp_list


def assert_login(self, login_dic, success, code, message):
    '''
    断言登录接口用例方法
    :param login_dic: 实际接口请求下来字典数据
    :param success: 预期是否成功
    :param code: 预期状态码
    :param message: 预期返回消息
    '''
    self.assertIn(message, login_dic['message'])
    self.assertEqual(success, login_dic['success'])
    self.assertEqual(code, login_dic['code'])



if __name__ == '__main__':
    parse_login_data()

